//最长公共前缀
public class Test01 {
    public String longestCommonPrefix(String[] strs) {
        String Prefix = strs[0];
        for (int i = 1; i < strs.length; i++) {
            Prefix = CommonPrefix(Prefix, strs[i]);
            if (Prefix.isEmpty()) {
                return "";
            }
        }
        return Prefix;
    }

    public String CommonPrefix(String s1, String s2) {
        int length = Math.min(s1.length(), s2.length());
        StringBuilder Prefix = new StringBuilder();
        for (int i = 0; i < length; i++) {
            if (s1.charAt(i) == s2.charAt(i)) {
                Prefix.append(s1.charAt(i));
            } else {
                break;
            }
        }
        return Prefix.toString();
    }
}
